<?php
class UserProfile extends A_UserProfile
{
	
	private 
		$_db_pref = "";
	
	protected function loader() {
		$get_profile = $this->_top->_sql->exe("SELECT * FROM {$this->_db_pref}".TAB_PREF."user_profile WHERE user_id={$this->_user_id}");
		if (count($get_profile)==0) {
			$this->_top->_sql->exeDummy("INSERT INTO {$this->_db_pref}".TAB_PREF."user_profile(user_id) VALUES({$this->_user_id})");
			$this->loader(true);
		} else {
			$this->_profile_data = $get_profile[0];
		}
	}
	
	public function __get($param) {
		if (!isset($this->_profile_data[$param])) { 
			return false;
		} else {
			return $this->_profile_data[$param];
		}
	
	}
	
	public function __set($param,$value) {
		if (!isset($this->_profile_data[$param]) || $param=="user_id") { 
			return false;
		} else {
			$value = $this->_top->Utils->prepareValueForSQL($value);
			
			$this->_top->_sql->exeDummy("UPDATE {$this->_db_pref}".TAB_PREF."user_profile
				SET $param='$value' WHERE user_id={$this->_user_id}");
			
			$this->_profile_data[$param] = $value;
			return true;
		}
	}
	
	
	public function delete() {
		$this->_top->_sql->exeDummy("DELETE FROM {$this->_db_pref}".TAB_PREF."user_profile WHERE user_id={$this->_user_id}");
		$this->_profile_data = false;
	}
	
}

?>